package com.fjrz.bbxwj.main.mine

import android.app.Activity
import android.content.Intent
import com.blankj.utilcode.util.FragmentUtils
import com.fjrz.bbxwj.R
import com.fjrz.bbxwj.main.video.base.VideoUserFragment
import com.module.lemlin.base.BaseAbstractActivity
import kotlinx.android.synthetic.main.activity_user_video.*

class UserVideoActivity : BaseAbstractActivity() {

    companion object {

        private const val EXTRA_KEY_USER_ID = "EXTRA_KEY_USER_ID"
        private const val EXTRA_KEY_POSITION = "EXTRA_KEY_POSITION"
        fun open(activity: Activity, userId: Int, position: Int) {
            val intent = Intent(activity, UserVideoActivity::class.java)
            intent.putExtra(EXTRA_KEY_USER_ID, userId)
            intent.putExtra(EXTRA_KEY_POSITION, position)
            activity.startActivity(intent)
        }
    }

    override val layoutResId: Int
        get() = R.layout.activity_user_video

    override fun stateBar(): StatusBar {
        return StatusBar(isLightMode = false, view = flUserVideoBar)
    }

    override fun initView() {

        val userId: Int = intent?.getIntExtra(EXTRA_KEY_USER_ID, (0)) ?: 0
        val position: Int = intent?.getIntExtra(EXTRA_KEY_POSITION, (0)) ?: 0
        val fragment: VideoUserFragment =
            VideoUserFragment.newInstance(userId, position, UserVideoFragment.VIDEO_LIST)
        FragmentUtils.add(supportFragmentManager, fragment, R.id.flUserVideoBody)

        ivUserVideoBack.setOnClickListener { finish() }
    }

}